package com.atguigu.java;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

public class ListTest {
    @Test
    public void test1(){
        ArrayList list = new ArrayList();
        list.add(111);
        list.add(222);
        list.add(333);
        list.add("aaa");
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));

        }
        System.out.println("=========================");
        Iterator iterator = list.iterator();
        while(iterator.hasNext()){
            System.out.println(iterator.next());
        }
        System.out.println("++++++++++++++++++++=");
        for(Object o:list){
            System.out.println(o);
        }

    }
    @Test
    public void test2(){
        ArrayList list = new ArrayList();
        list.add(123);
        list.add(456);
        list.add("aaa");
        list.add(new Person("tom",22));
        list.add(456);
        int i = list.indexOf(456);
        System.out.println(i);
        int i1 = list.lastIndexOf(456);
        System.out.println(i1);
//        Object obj = list.remove(0);
//        System.out.println(obj);
        System.out.println(list);
        list.set(1,"gg" );
        System.out.println(list);
        List list1 = list.subList(2, 4);
        System.out.println(list1);
        System.out.println(list);


    }
}
